package zs.zsxmlv.action;

import common.zsxmlv.vo.Result;
import common.zsxmlv.vo.Table;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import zs.zsxmlv.po.Note;
import zs.zsxmlv.service.NoteService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author: ZSXM
 * @Description:
 * @Company: DingZheng
 * @Date: Create by 2018/5/22 0:09
 * @Version: 1.0
 * @Modify by:
 */
@Controller
@ResponseBody
@RequestMapping("/admin/note")
public class NoteAction {

    @Resource
    private NoteService noteService;

    /**
     * 保存笔记
     * @param content 笔记内容文本
     * @param note 笔记相关字段信息
     * @return result
     */
    @RequestMapping("/insert")
    public Result insert(String content, Note note, HttpServletRequest request){
        return noteService.insertNote(content,note);
    }

    /**
     * 分页查询数据
     * @param page 页码
     * @param limit 每页大小
     * @return layui data table
     */
    @RequestMapping("/selectByList")
    public Table selectByList(Integer page, Integer limit) {
        return noteService.selectByList(page, limit);
    }

    /**
     * 根据笔记ID查询笔记
     * @param id 笔记ID(32位随机字符串UUID)
     * @return result
     */
    @RequestMapping("/selectByKey")
    public Result selectByPrimaryKey(String id) {
        return noteService.selectByPrimaryKey(id);
    }

    /**
     * 根据笔记ID删除数据
     * @param id 笔记ID
     * @return result
     */
    @RequestMapping("/deleteById")
    public Result deleteById(String id) {
        return noteService.deleteById(id);
    }

}
